package com.bjsxt.usersCenter.system.pojo;

import java.util.Date;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bjsxt.usersCenter.common.util.DateFormatUtil;

/**
 * 地区表的pojo
 * @author Administrator
 *id	int	11	0	0	-1	0	0	0		0					-1	0
parentId	int	11	0	0	0	0	0	0		0	上一级id				0	0
name	varchar	255	0	0	0	0	0	0		0	名称	utf8	utf8_general_ci		0	0
areacode	varchar	255	0	0	0	0	0	0		0	地区码	utf8	utf8_general_ci		0	0
content	text	0	0	0	0	0	0	0		0	内容介绍	utf8	utf8_general_ci		0	0
status	tinyint	4	0	0	0	0	0	0		0	状态:0:禁用;1:启用				0	0
createTime	datetime	0	0	0	0	0	0	0		0	创建时间				0	0
updateTime	datetime	0	0	0	0	0	0	0		0	更新时间				0	0
pubTime	datetime	0	0	0	0	0	0	0		0	发布时间(用来排序)				0	0

 */
public class ARegion
{
	private int id;
	private int parentId;
	private String name;
	private String pinyin;
	private String areacode;
	private String content;
	private byte status;
	private byte leafStatus;
	private Date createTime;
	private Date updateTime;
	private Date pubTime;
	
	
	//对象的表示关系
	private ARegion parentRegion;
	
	//属性分类的字符串表示
	private String treeName;
	private String leafStatusStr;
	private String statusStr;
	
	
	//json的表现方式
	
	private JSONArray treeJSON;
	private JSONArray childrenListJSON;
	
	
	public int getId()
	{
		return id;
	}
	public void setId(int id)
	{
		this.id = id;
	}
	public int getParentId()
	{
		return parentId;
	}
	public void setParentId(int parentId)
	{
		this.parentId = parentId;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public String getAreacode()
	{
		return areacode;
	}
	public void setAreacode(String areacode)
	{
		this.areacode = areacode;
	}
	public String getContent()
	{
		return content;
	}
	public void setContent(String content)
	{
		this.content = content;
	}
	public byte getStatus()
	{
		return status;
	}
	public void setStatus(byte status)
	{
		this.status = status;
	}
	public Date getCreateTime()
	{
		return createTime;
	}
	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}
	public Date getUpdateTime()
	{
		return updateTime;
	}
	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}
	public Date getPubTime()
	{
		return pubTime;
	}
	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}
	public String getPinyin()
	{
		return pinyin;
	}
	public void setPinyin(String pinyin)
	{
		this.pinyin = pinyin;
	}
	public byte getLeafStatus()
	{
		return leafStatus;
	}
	public void setLeafStatus(byte leafStatus)
	{
		this.leafStatus = leafStatus;
	}
	public ARegion getParentRegion()
	{
		return parentRegion;
	}
	public void setParentRegion(ARegion parentRegion)
	{
		this.parentRegion = parentRegion;
	}
	public String getTreeName()
	{
		return treeName;
	}
	public void setTreeName(String treeName)
	{
		this.treeName = treeName;
	}
	public JSONArray getTreeJSON()
	{
		return treeJSON;
	}
	public void setTreeJSON(JSONArray treeJSON)
	{
		this.treeJSON = treeJSON;
	}
	public JSONArray getChildrenListJSON()
	{
		return childrenListJSON;
	}
	public void setChildrenListJSON(JSONArray childrenListJSON)
	{
		this.childrenListJSON = childrenListJSON;
	}
	public String getLeafStatusStr()
	{
		
		ARegionEnum[] regionEnums=ARegionEnum.values();
		
		
		for (int i = 0; i < regionEnums.length; i++)
		{
			ARegionEnum regionEnum=regionEnums[i];
			if(regionEnum.toString().startsWith("LEAFSTATUS_")){
				
				
				if(regionEnum.getStatus()==this.getLeafStatus())
				{
					this.leafStatusStr=regionEnum.getInfo();
					
					break;
				}
				
				
			}
		}
		
		
		
		
		
		return leafStatusStr;
	}
	public String getStatusStr()
	{
		

		ARegionEnum[] regionEnums=ARegionEnum.values();
		
		
		for (int i = 0; i < regionEnums.length; i++)
		{
			ARegionEnum regionEnum=regionEnums[i];
			if(regionEnum.toString().startsWith("STATUS_")){
				
				
				if(regionEnum.getStatus()==this.getStatus())
				{
					this.statusStr=regionEnum.getInfo();
					
					break;
				}
				
				
			}
		}
		
		
		
		
		return statusStr;
	}
	public JSONObject toJSON()
	{
		DateFormatUtil dateFormatUtil=new DateFormatUtil();
		
		JSONObject regTempJSON=new JSONObject();
		regTempJSON.put("id", this.getId() + "");
		regTempJSON.put("parentid", this.getParentId() + "");
		regTempJSON.put("name", this.getName());
		regTempJSON.put("pinyin", this.getPinyin());
		regTempJSON.put("areacode", this.getAreacode());
		regTempJSON.put("content", this.getContent());
		regTempJSON.put("leafStatus", this.getLeafStatus() + "");
		regTempJSON.put("createtime", dateFormatUtil.format(this.getCreateTime()));
		regTempJSON.put("updatetime", dateFormatUtil.format(this.getUpdateTime()));
		regTempJSON.put("pubTime", dateFormatUtil.format(this.getPubTime()));
		regTempJSON.put("treeName", this.getTreeName());
		
		if(treeJSON!=null)
		{
			regTempJSON.put("treeJSON", treeJSON);
		}
		if(childrenListJSON!=null)
		{
			regTempJSON.put("childrenListJSON", childrenListJSON);
		}
		return regTempJSON;
	}
	
	
	
	
	
	
	
	
}
